/*
 * walk.c
 *
 *  Created on: 2017年4月10日
 *      Author: zhikang.peng
 */

#include "system-api.h"

void HariMain(void) {
	char *buf;
	int win, i, x, y;
	api_initmalloc();
	buf = api_malloc(160 * 100);
	win = api_openwindos(buf, 160, 100, -1, "walk");
	api_boxwindosfill(win, 4, 24, 155, 95, 0);
	x = 76;
	y = 56;

	api_putwindostext(win, x, y, 3, 1, "*");
	for (;;) {
		i = api_getKeyboardData(1);
		api_putwindostext(win, x, y, 0, 1, "*");
		if (i == '4' && x > 4) x -= 8;
		if (i == '6' && x < 148) x += 8;
		if (i == '8' && y > 24) y -= 8;
		if (i == '2' && y < 80) y += 8;
		if (i == 0x0a) {
			api_closeWindos(win);
			break;
		}
		api_putwindostext(win, x, y, 3, 1, "*");
	}
	api_end();
}
